package com.shejimoshi.简单工厂模式.反射的方式;

import com.shejimoshi.简单工厂模式.common.Video;

public class VideoFactoryReflact {
    /**
     * 使用反射创建对象
     */
    public static Video getVideo(Class c) {
        Video video = null;
        try{
            video = (Video) Class.forName(c.getName()).newInstance();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        return video;
    }
}
